home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / August 96 / Store a reference to another pa < prev    next >
Encoding:
Internet Message Format  |  1996-08-23  |  2.1 KB  |  [TEXT/ttxt]

  1. Subject:     Store a reference to another part
  2. Sent:        8/23/96 2:31 AM
  3. Received:    8/23/96 9:15 AM
  4. From:        Steinar.Tyvand@si.sintef.no
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. I am making a part that needs to persistantly store a reference to another
  9. part in the same document.
  10. Will the following code work?
  11.  
  12. Should I save the references in the kODPropContents property, adding a
  13. kODStrongStorageUnitRef value type to the property?
  14.  
  15. Steinar
  16. //--------------------------------------------------------------
  17. // Persistant storage of pointers to other parts in the system
  18.     ODPart* fOtherPart;
  19.     
  20. // Externalize
  21. // Get the storage unit to the part
  22.     ODStorageUnit    otherSU = fOtherPart->GetStorageUnit(ev);
  23.  
  24. // Get the StorageUnit ID
  25.     ODStorageUnitID otherSUID = otherSU->GetID(ev);
  26.     
  27.     ODStorageUnitRef strongRef;
  28.     FW_CByteArray byteArray(&strongRef, sizeof(ODStorageUnitRef));
  29.  
  30. // Get a strong reference from the other storage unit    
  31.     suView->GetStrongStorageUnitRef(ev, otherSUID, strongRef);
  32.  
  33. // Save it in this storage unit
  34.     suView->SetValue(ev, byteArray);
  35.     
  36.     
  37. // Internalize
  38.     ODStorageUnitRef strongRef;    
  39.     FW_CByteArray byteArray;
  40.         
  41. // Read reference
  42.     suView->GetValue(ev, sizeof(ODStorageUnitRef), byteArray);
  43.     byteArray.CopyBuffer(&strongRef, sizeof(ODStorageUnitRef));
  44.     
  45.     if (!suView->IsValidStorageUnitRef(ev, strongRef))
  46.         return FALSE;
  47.  
  48. // Get ID of other StorageUnit    
  49.     ODStorageUnitID otherSUID = suView->GetIDFromStorageUnitRef(ev, aSURef);
  50.  
  51. // Get the draft    
  52.     ODDraft* draft = suView->GetStorageUnit(ev)->GetDraft(ev);
  53.  
  54. // Acquire other part                
  55.     fOtherPart = draft->AcquirePart(otherSUID);
  56.  
  57.  
  58.  
  59. --------------------------------------------------------------
  60. Steinar Tyvand             e-mail: Steinar.Tyvand@unimed.sintef.no
  61. SINTEF Unimed Rehab        Phone:  +47 22 06 78 29 (work)
  62. Box 124 Blindern           Fax:    +47 22 06 79 09 (work)
  63. N-0314 Oslo                Phone:  +47 67 56 17 79 (home)
  64. Norway                     Fax:    +47 67 56 05 36 (home)
  65. --------------------------------------------------------------
  66.  
  67.